package com.linesum.code.design.factory;

/**
* 
* @author chenzf
* @date 2017年8月1日
*/
@SuppressWarnings("static-method")
public class StoreFactory {
	private static StoreFactory storeFactory = null;

	public static StoreFactory getInstance() {
		storeFactory = new StoreFactory();
		return storeFactory;
	}

	public Store createStore(String type) {
		switch (type) {
		case "001":
			return createClothesStore();
		case "002":
			return createShoesStore();
		default:
			throw new RuntimeException("未找到店铺");
		}
	}

	private ClothesStore createClothesStore() {
		ClothesStore clothesStore = new ClothesStore();
		clothesStore.setCode("001");
		clothesStore.setManager("admin");
		clothesStore.setName("衣服店");
		clothesStore.setType("卖衣服");
		return clothesStore;
	}

	private ShoesStore createShoesStore() {
		ShoesStore shoesStore = new ShoesStore();
		shoesStore.setCode("002");
		shoesStore.setName("鞋子店");
		shoesStore.setType("卖鞋子");
		shoesStore.setAddress("福建，厦门");
		return shoesStore;
	}

	public static void main(String[] args) {
		StoreFactory factory = StoreFactory.getInstance();
		Store createStore = factory.createStore("001");
		System.out.println(createStore);
	}
}
